package com.shenzhenai.module_principles.demo2.after;

/**
 * @author huangzehui
 * @date 2025/8/13 13:06 周三
 * @description 13.设计模式-设计原则(里氏代换原则案例改进)
 * https://www.bilibili.com/video/BV1Yt4y1B7Cm?spm_id_from=333.788.player.switch&vd_source=e07cc8cc94eb22bd76722071b03cd199&p=13
 */
public class RectangleDemo {

    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle();
        rectangle.setLength(20);
        rectangle.setWidth(10);

        resize(rectangle);
        printLengthAndWidth(rectangle);

        Square square = new Square();
        square.setSide(10);

        printLengthAndWidth(square);
    }


    // 拓宽的方法
    public static void resize(Rectangle rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    // 打印长和宽
    public static void printLengthAndWidth(Quadrilateral quadrilateral) {
        System.out.println(quadrilateral.getLength());
        System.out.println(quadrilateral.getWidth());
    }
}
